package com.ruoyi.project.mgcmanage.service.impl;


import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.project.mgcmanage.domain.Supplier;
import com.ruoyi.project.mgcmanage.mapper.SupplierMapper;
import com.ruoyi.project.mgcmanage.service.ISupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class SupplierServiceImpl implements ISupplierService {

    @Autowired
    private SupplierMapper supplierMapper;

    @Override
    public List<Supplier> selectAll(Supplier supplier) {
        return supplierMapper.selectAll(supplier);
    }

    @Override
    public int addSupplier(Supplier supplier) {
        supplier.setCreateBy(SecurityUtils.getUsername());
        supplier.setCreateTime(new Date());
        return supplierMapper.insert(supplier);
    }

    @Override
    public Supplier selectById(int sid) {
        return supplierMapper.selectOne(sid);
    }

    @Override
    public int updateSupplier(Supplier supplier) {
        supplier.setUpdateBy(SecurityUtils.getUsername());
        supplier.setUpdateTime(new Date());
        return supplierMapper.update(supplier);
    }

    @Override
    public int delete(int[] sids) {
        return supplierMapper.delete(sids);
    }

    @Override
    public List<Supplier> selectSupplierNames() {
        return supplierMapper.selectByNames();
    }
}
